#ifndef _DYNAMICPROPERTYLIST_H_
#define _DYNAMICPROPERTYLIST_H_

#include "BoardGameEngine.h"
#include "DynamicPropertyValue.h"
#include <map>

using namespace std;


_BEGIN_BOARDGAME_NAMESPACE_


typedef map<tstring, DynamicPropertyValue> PropertyMap;


class DynamicPropertyList
{
public:
	DynamicPropertyList();

	const PropertyMap &					GetProperties() const;

	void								AddProperty( const tstring & name, DynamicPropertyType type );

	const DynamicPropertyValue &		GetValue( const tstring & name ) const;

	void								SetValue( const tstring & name, bool value );
	void								SetValue( const tstring & name, int value );
	void								SetValue( const tstring & name, float value );
	void								SetValue( const tstring & name, const tchar * value );
	void								SetValue( const tstring & name, const tstring & value );

private:
	void								CheckNameUniqueness( const tstring & name ) const;

										template<typename T>
	void								SetData( const tstring & name, const T & data );

	PropertyMap							m_properties;
};


template<typename T>
void DynamicPropertyList::SetData( const tstring & name, const T & data )
{
	PropertyMap::iterator it = m_properties.find( name );
	if( it == m_properties.end() )
	{
		throw invalid_argument( "Property with specific name does not existed." );
	}

	it->second = data;
}


_END_BOARDGAME_NAMESPACE_

#endif